package com.mexico.inloancash.india_basepresent;

import java.lang.ref.WeakReference;

/**
 * @author zx
 * @description
 * @date 2020/4/24.
 */
public abstract class BasePresent<V> {
    private WeakReference<V> viewWeakReference;
    public void attachView(V view){
        viewWeakReference = new WeakReference<>(view);
    }
    protected V getView(){
        return viewWeakReference.get();
    }

    public boolean isViewAttached(){
        return viewWeakReference != null && viewWeakReference.get()!= null;
    }

    public void detachView(){
        if (viewWeakReference != null){
            viewWeakReference.clear();
            viewWeakReference = null;
        }
    }
}
